import cv
import numpy
import cPickle
import rescale

cv.NamedWindow('RGB')
a = open('/media/disk/two_fists_depth.data')
dData = cPickle.load(a)
iData = cPickle.load(open('/media/disk/two_fists_image.data'))

frame = dData[0]
image = cv.CreateImageHeader((frame.shape[1], frame.shape[0]), cv.IPL_DEPTH_16U,1)
cv.SetData(image, frame.tostring(), frame.dtype.itemsize * frame.shape[1])
#while(1):
#    cv.ShowImage('Depth', image)
#    cv.WaitKey(40)

iframe = iData[0]
#print frame
frame = rescale.frame(frame)
print frame
#print iframe
while(1):
    image = cv.CreateImageHeader((frame.shape[1], frame.shape[0]), cv.IPL_DEPTH_8U,3)
     # Note: We swap from RGB to BGR here
    cv.SetData(image, frame[:, :, ::-1].tostring(), frame.dtype.itemsize * 3 * frame.shape[1])
    cv.ShowImage('RGB', image)
    cv.WaitKey(40)

#image = cv.CreateImageHeader((frame.shape[1], frame.shape[0]), cv.IPL_DEPTH_16U,1)
#cv.SetData(image, frame.tostring(), frame.dtype.itemsize * frame.shape[1])
#cv.ShowImage('Depth', image)
#cv.WaitKey(3)
##
